package tx.core;

/**
 * The set of all blocks that are still on the board.
 * @author Guilherme Mauro Germoglio Barbosa - germoglio@gmail.com
 */
public class Blocks {
	
	/**
	 * Maximum number of blocks allowed pilled up in a single column.
	 */
	private static final int MAX_BLOCKS_HEIGHT = 20;
	
	/**
	 * Maximum number of blocks side by side.
	 */
	private static final int MAX_BLOCKS_WIDTH = 10;
	
	/**
	 * The blocks.
	 */
	private final Block[][] blocks;
	
	/**
	 * Creates a new Blocks. Empty, of course.
	 */
	public Blocks() {
		this.blocks  = new Block[MAX_BLOCKS_HEIGHT][MAX_BLOCKS_WIDTH];
	}

	/**
	 * Updates all blocks.
	 * @param elapsedTime The time elapsed.
	 */
	public void update(long elapsedTime) {
		for (int i = MAX_BLOCKS_HEIGHT - 1; i >= 0; i--) {
			for (int j = MAX_BLOCKS_WIDTH - 1; j >= 0; j--) {
				if (blocks[i][j] != null) blocks[i][j].update(elapsedTime);
			}
		}
	}
	
}
